import axios from './request'
export const get = (url: string, params = {}) => {
  return new Promise((resolve, reject) => {
    return axios({
      url: url,
      method: 'get',
      params: params,
    })
      .then((res) => {
        resolve(res)
      })
      .catch((err) => {
        reject(err)
      })
  })
}
export const posts = (url: string, params = {}) => {
  return new Promise((resolve, reject) => {
    axios({
      url: url,
      method: 'post',
      data: params,
      headers: {
        'Content-Type': 'multipart/form-data',
      },
    })
      .then((res) => {
        resolve(res)
      })
      .catch((err) => {
        reject(err)
      })
  })
}
export const post = (url: string, params = {}) => {
  return new Promise((resolve, reject) => {
    axios({
      url: url,
      method: 'post',
      data: params,
    })
      .then((res) => {
        resolve(res)
      })
      .catch((err) => {
        reject(err)
      })
  })
}
export const put = (url: string, params = {}) => {
  return new Promise((resolve, reject) => {
    axios({
      url: url,
      method: 'put',
      data: params || {},
    })
      .then((res) => {
        resolve(res)
      })
      .catch((err) => {
        reject(err)
      })
  })
}
export const puts = (url: string, params = {}) => {
  return new Promise((resolve, reject) => {
    axios({
      url: url,
      method: 'put',
      data: params || {},
      headers: {
        'Content-Type': 'multipart/form-data',
      },
    })
      .then((res) => {
        resolve(res)
      })
      .catch((err) => {
        reject(err)
      })
  })
}
export const patch = (url: string, params = {}) => {
  return new Promise((resolve, reject) => {
    axios({
      url: url,
      method: 'patch',
      data: params || {},
    })
      .then((res) => {
        resolve(res)
      })
      .catch((err) => {
        reject(err)
      })
  })
}
export const deletes = (url: string, params = {}) => {
  return new Promise((resolve, reject) => {
    axios({
      url: url,
      method: 'delete',
      data: params,
    })
      .then((res) => {
        resolve(res)
      })
      .catch((err) => {
        reject(err)
      })
  })
}
